package vip.liux.contracts.models.notification;

import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import vip.liux.contracts.shared.enums.Status;
import vip.liux.contracts.shared.enums.messing.ChannelType;
import vip.liux.domain.entities.auditing.CreationAuditedEntity;
import vip.liux.orm.jpa.converts.MapObjectConvert;

import java.util.Map;

/**
 * 通知模板实体类
 * 表示通知的模板信息
 */
@Getter
@Setter
@Entity
@Table(name = "message_template")
public class MessageTemplate extends CreationAuditedEntity<Long> {

    /**
     * 模板名称
     */
    @Column(name = "template_name", nullable = false, length = 100)
    private String templateName;
    
    /**
     * 模板编码
     */
    @Column(name = "template_code", nullable = false, length = 100)
    private String templateCode;

    /**
     * 标题
     */
    @Column(name = "title", nullable = false)
    private String title;

    /**
     * 模板内容
     */
    @Column(name = "content", nullable = false)
    private String content;

    /**
     * 通知渠道类型 0 - 站内消息 1 - 短信 2 - 邮件 3 - Webhooks
     *
     * @see ChannelType
     */
    @Column(name = "channel_type", nullable = false)
    @Enumerated(EnumType.ORDINAL)
    private ChannelType channelType;

    /**
     * 变量映射
     */
    @Column(name = "variables")
    @Convert(converter = MapObjectConvert.class)
    private Map<String, Object> variables;

    /**
     * 模板描述
     */
    @Column(name = "description")
    private String description;

    /**
     * 模板状态 0 - 启用 1 - 禁用
     *
     * @see Status
     */
    @Column(name = "status", nullable = false)
    @Enumerated(EnumType.ORDINAL)
    private Status status;
}